package top.zuli.package01.class16;

import org.junit.Test;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;

public class Demo6 {
    @Test
    public void ZoneIdMethodTest2() {
        //1.封装LocalDateTime对象，
        LocalDateTime localDateTime = LocalDateTime.of(2012,12,12,23,8,8);
        //2.为localDateTime封装时区
        ZonedDateTime zonedDateTime = localDateTime.atZone(ZoneId.of("Asia/Shanghai"));
        System.out.println(zonedDateTime);
        //3.更改时区查看其他时区的当前时间，通过withZoneSameInstant()
        ZonedDateTime zonedDateTime1 = zonedDateTime.withZoneSameInstant(ZoneId.of("Asia/Tokyo"));
        System.out.println(zonedDateTime1);
    }
}

/*
public class Demo6 {
    @Test
    public void ZoneIdMethodTest2() {
        LocalDateTime localDateTime = LocalDateTime.of(2012,12,12,23,8,8);
        ZonedDateTime zonedDateTime = localDateTime.atZone(ZoneId.of("Asia/Shanghai"));
        System.out.println(zonedDateTime);
        ZonedDateTime zonedDateTime1 = zonedDateTime.withZoneSameInstant(ZoneId.of("Asia/Tokyo"));
        System.out.println(zonedDateTime1);
    }
}
*/
